package com.test.gpa.test.socket;


import java.util.*;
import java.util.stream.Collectors;

public class sFa {
    public static void main(String[] args) {
//        String A = "AAA";
//        String B = "AAA";
//        System.out.println(A == B);
//        String C = new String("AAA");
//        String D = new String("AAA");
//        System.out.println(B == C);
//        System.out.println(C == D);
//        System.out.println(C.equals(B));
        int i = maxProduct(new int[]{3, 9, -6});
        System.out.println(i);
    }

    public int[] buildArray(int[] nums) {
        if (nums == null) {
            return new int[0];
        }
        int[] a = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            a[i] = nums[nums[i]];
        }
        return a;
    }

    public static int eliminateMaximum(int[] dist, int[] speed) {
        List<Integer> list = new ArrayList();
        for (int i = 0; i < dist.length; i++) {
            int b = (dist[i] + speed[i] - 1) / speed[i] - 1;
            System.out.println(b);
            list.add(b);
        }

        List<Integer> collect = list.stream().sorted().collect(Collectors.toList());
        for (int i = 0; i < collect.size(); i++) {
            if (collect.get(i) < i) {
                return i;
            }
        }
        return dist.length;
    }

    public List<List<Integer>> minimumAbsDifference(int[] arr) {

        List<List<Integer>> listOut = new ArrayList<>();
        Arrays.sort(arr);
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < arr.length - 1; i++) {
            int a = arr[i + 1] - arr[i];
            if (a < min) {
                listOut.clear();
                List<Integer> list = new ArrayList();
                list.add(arr[i]);
                list.add(arr[i + 1]);
                listOut.add(list);
                min = a;
            } else if (a == min) {
                List<Integer> list = new ArrayList();
                list.add(arr[i]);
                list.add(arr[i + 1]);
                listOut.add(list);
            }
        }

        return listOut;
    }

    public static String decodeMessage(String key, String message) {
        String re = "";

        Map<Character, Integer> map = new HashMap();
        int count = 0;
        for (int i = 0; i < key.length(); i++) {
            if (key.charAt(i) == ' ') continue;
            if (!map.containsKey(key.charAt(i))) {
                map.put(key.charAt(i), count);
                count++;
            }
            if (count > 26) break;
        }


        for (int i = 0; i < message.length(); i++) {
            char a = message.charAt(i);
            if (a == ' ') {
                re = re + a;
            } else {
                int d = map.get(a);
                char c = (char) (d + 97);
                re = re + c;
            }

        }
        return re;


    }

    public String replaceSpace(String s) {


        List<String> collect = Arrays.stream(s.split("")).map(x -> {
            if (x.equals(" ")) return "%20";
            else return x;

        }).collect(Collectors.toList());
        String a = "";
        for (int i = 0; i < collect.size(); i++) {
            a = a + collect.get(i);
        }
        return a;
    }

    public static int maxProduct(int[] nums) {
        if (nums.length < 2) return nums[0];

        int count = nums[nums.length - 1];
        for (int i = 0; i < nums.length - 1; i++) {
            int nums1 = 1;
            for (int j = i; j < nums.length; j++) {
                nums1 = nums[j] * nums1;
                if (nums1 > count) {
                    count = nums1;
                }
            }
        }
        return count;

    }

}

class Node {
    int key;
    int hash;
    Node nextNode;

    public Node(int key) {
        this.key = key;

    }
}

class MyHashSet {
    int size = 64;

    Node[] ints;


    public int hashCode1(int key) {
        return key % size;
    }

    public MyHashSet() {
        ints = new Node[size];
    }

    public void add(int key) {
        int nums = hashCode1(key);
        Node node = ints[nums];
        if (node == null) {
            ints[nums] = new Node(key);
            return;
        }
        while (node.nextNode != null) {
            node = node.nextNode;
        }
        node.nextNode = new Node(key);
    }

    public void remove(int key) {
        if (!contains(key)) return;
        int nums = hashCode1(key);
        Node node = ints[nums];
        if (node.key == key) ints[nums] = null;
        Node node1 = node;
        while (node != null) {
            if (node.key == key) node1.nextNode = node.nextNode;
            node1 = node;
            node = node.nextNode;
        }
    }

    public boolean contains(int key) {
        Node node = ints[hashCode1(key)];
        if (node == null) return false;

        while (node != null) {
            if (key == node.key) return true;
            node = node.nextNode;
        }
        return false;
    }
}